#ifndef SYSCLIENTSOCKET_H
#define SYSCLIENTSOCKET_H

#include "cnsMacroGlobal.h"
#include "framework.h"
#include "client-socket_global.h"
#include <QThread>
#include <uv.h>
#include "baseproto.h"
#include "client-socket.h"

class SysClientSocket : public QObject
{
    Q_OBJECT
public:
    Q_INVOKABLE SysClientSocket();
    static void _on_read(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf);
    static void _on_disconnect(uv_handle_t* handle);
    Q_INVOKABLE void f__on_connect(CnsComponentPtr com, uv_connect_t* req, int status);
    void client_read(ClientSocketProcPtr client);
    Q_INVOKABLE void f_run(CnsComponentPtr com, uv_loop_t *loop);
    static void client_disconnect(ClientSocketProc* client, uv_close_cb callback);
    static void _on_alloc_buffer(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
};

Q_DECLARE_METATYPE(SysClientSocket*)

#endif // SYSCLIENTSOCKET_H
